Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds a new Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying patternfly-doc-core with
|
| Latest commit: |
23126ca
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://143b082c.patternfly-doc-core.pages.dev |
| Branch Preview URL: | https://add-api-only-build-mode.patternfly-doc-core.pages.dev |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/pages/[section]/[page]/[tab].astro (1)
33-44: Move theapiOnlycheck before fetching collections to avoid unnecessary work.When
PF_API_ONLYis'true', collections are fetched viaPromise.alland then immediately discarded. Move the early return to the top ofgetStaticPaths()to skip the async operations entirely.♻️ Proposed optimization
export async function getStaticPaths() { + if (process.env.PF_API_ONLY === 'true') { + return [] + } + const collections = await Promise.all( content.map( async (entry) => await getCollection(entry.name as 'textContent'), ), ) - - const apiOnly = process.env.PF_API_ONLY === 'true' - - if (apiOnly) { - return [] - } const flatCol = collections🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/`[section]/[page]/[tab].astro around lines 33 - 44, In getStaticPaths(), check the apiOnly flag (process.env.PF_API_ONLY === 'true') and return [] before starting the Promise.all that maps over content and calls getCollection; specifically move the apiOnly check to the top of the getStaticPaths function so you avoid invoking content.map, getCollection, and Promise.all when apiOnly is true.src/pages/[section]/[...page].astro (1)
32-43: Move theapiOnlycheck before fetching collections.Same issue as in
[tab].astro— the collections are fetched before checkingPF_API_ONLY, wasting async work when API-only mode is enabled.♻️ Proposed optimization
export async function getStaticPaths() { + if (process.env.PF_API_ONLY === 'true') { + return [] + } + const collections = await Promise.all( content.map( async (entry) => await getCollection(entry.name as 'textContent'), ), ) - - const apiOnly = process.env.PF_API_ONLY === 'true' - - if (apiOnly) { - return [] - } return collections.flat().map((entry) => {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/`[section]/[...page].astro around lines 32 - 43, In getStaticPaths, check PF_API_ONLY early and return if true before starting any async work: move the apiOnly (const apiOnly = process.env.PF_API_ONLY === 'true') check to the top of the function and return [] immediately when true so you avoid calling getCollection or iterating over content; update references to content and getCollection accordingly to only run when not in API-only mode.cli/cli.ts (1)
198-198: Clarify the option description.The description says "skip standalone content pages" but based on the implementation, ALL content pages (both
[section]/[...page].astroand[section]/[page]/[tab].astro) are skipped when this flag is set. Consider updating the description to be more accurate.📝 Suggested clarification
-program.option('--api-only', 'only build API and component pages, skip standalone content pages', false) +program.option('--api-only', 'only build API routes, skip all content pages', false)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/cli.ts` at line 198, The --api-only option description is misleading: update the program.option call for '--api-only' (in cli.ts where program.option is defined) to state that it skips all content pages (both standalone and nested content routes such as [section]/[...page].astro and [section]/[page]/[tab].astro), not just "standalone" pages; keep the same flag name and default value but change the human-readable description to accurately reflect that all content pages are omitted when this flag is set.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cli/cli.ts`:
- Line 198: The --api-only option description is misleading: update the
program.option call for '--api-only' (in cli.ts where program.option is defined)
to state that it skips all content pages (both standalone and nested content
routes such as [section]/[...page].astro and [section]/[page]/[tab].astro), not
just "standalone" pages; keep the same flag name and default value but change
the human-readable description to accurately reflect that all content pages are
omitted when this flag is set.
In `@src/pages/`[section]/[...page].astro:
- Around line 32-43: In getStaticPaths, check PF_API_ONLY early and return if
true before starting any async work: move the apiOnly (const apiOnly =
process.env.PF_API_ONLY === 'true') check to the top of the function and return
[] immediately when true so you avoid calling getCollection or iterating over
content; update references to content and getCollection accordingly to only run
when not in API-only mode.
In `@src/pages/`[section]/[page]/[tab].astro:
- Around line 33-44: In getStaticPaths(), check the apiOnly flag
(process.env.PF_API_ONLY === 'true') and return [] before starting the
Promise.all that maps over content and calls getCollection; specifically move
the apiOnly check to the top of the getStaticPaths function so you avoid
invoking content.map, getCollection, and Promise.all when apiOnly is true.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: de1b334e-ff88-4b15-9053-2a4e6cb29fd2
📒 Files selected for processing (5)
cli/cli.tssrc/pages/404.astrosrc/pages/[section]/[...page].astrosrc/pages/[section]/[page]/[tab].astrosrc/pages/index.astro
|
🎉 This PR is included in version 1.22.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #212
Summary by CodeRabbit
Release Notes
--api-onlyCLI flag to enable API-only mode that omits standalone content pages while keeping API routes available.